package com.cheng.common.exception;

import com.cheng.common.utils.CodeUtil;

import javax.naming.AuthenticationException;
import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @author: ChengJW
 * @date: 2021/11/1 20:26
 * @version: 1.0
 * @description: 自定义异常
 */
public class CommonException extends RuntimeException{

    /** 异常代码*/
    private String code;

    /** 异常信息*/
    private String msg;

    /** 异常方法*/
    private String methodName;

    /** 异常类*/
    private String className;

    /** 异常*/
    private Throwable e;

    private String desc;

    public CommonException(){

    }

    /**
    * @author: ChengJW
    * @params: [code, className, methodName]
    * @return:
    * @date: 2021/11/2
    * @description: 异常代码+类名+方法名
    */
    public CommonException(String code,String className,String methodName){
        this.code = code;
        this.msg = CodeUtil.CODE_MAP.get(code);
        this.className = className;
        this.methodName = methodName;
    }

    /**
    * @author: ChengJW
    * @params: [code, className, methodName, e]
    * @return:
    * @date: 2021/11/2
    * @description: 异常代码+类名+方法名+异常
    */
    public CommonException(String code,String className,String methodName,Throwable e){
        this.code = code;
        this.className = className;
        this.methodName = methodName;
        this.e = e;
        this.desc = e.getMessage();
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Throwable getE() {
        return e;
    }

    public void setE(Throwable e) {
        this.e = e;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
